<%@page import="web.vungsi"%><%@page import="java.sql.*"%><%@page contentType="text/html" pageEncoding="UTF-8"%><%
String user_id = request.getParameter("uid");
String post_id = request.getParameter("pid");

String koneksiURL = "jdbc:mysql://localhost/progin_171_13509024?user=progin&password=progin";
Connection koneksi = null;
Statement statement = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
koneksi = DriverManager.getConnection(koneksiURL);
statement = koneksi.createStatement();


String igna = "INSERT INTO tbl_like(user_id, post_id) VALUES('"+user_id+"' , '"+post_id+"')";
int predo = statement.executeUpdate(igna);
if (predo!=0){
    ResultSet ambilTebel = statement.executeQuery("SELECT like_count FROM tbl_post WHERE id="+post_id);
    ambilTebel.next();
    int like_count = ambilTebel.getInt("like_count");
    like_count++;
    String ubahLike = "UPDATE tbl_post SET like_count='"+like_count+"' WHERE id="+post_id;
    int dodo = statement.executeUpdate(ubahLike);
}
out.print("bener");
%>
